module RF                        #钢筋类
    
    
    def RF.straight(length,dim,entities)
        
        

        points = [
            Geom::Point3d.new(0,   0,   0),
            Geom::Point3d.new(length, 0,   0)
        ]
        edges = entities.add_line points[0],points[1]

        vector = Geom::Vector3d.new 1,0,0
        vector2 = vector.normalize!
        face = entities.add_face(entities.add_circle points[1], vector2, dim/2)
        face.followme(edges.all_connected)

    end


    def RF.oneElbow(length,elbowLength1,dim,parentGroup)
        
        group2 = Sketchup.active_model.active_entities.add_group
        group3 = Sketchup.active_model.active_entities.add_group 
        
        group2.entities.add_group(parentGroup)
        group = group2.entities.add_group(group3)
        

        entities = group.entities

        points = [
            Geom::Point3d.new(0,  dim/2, 0),
            Geom::Point3d.new(length-dim*3, dim/2,  0),
            Geom::Point3d.new(length-dim/2, dim*3,   0),
            Geom::Point3d.new(length-dim/2, elbowLength1,   0)
        ]
        edges = entities.add_line points[0],points[1]
        edges = entities.add_line points[2],points[3]

        cpoint = Geom::Point3d.new(length-dim*3, dim*3,   0)
        vector = Geom::Vector3d.new 0,0,1
        vector2 = Geom::Vector3d.new 1,0,0
        vector3 = vector.normalize!
        entities.add_arc cpoint, vector2, vector3, 2.5*dim, 270.degrees, 360.degrees
        
        vector = Geom::Vector3d.new 1,0,0
        vector2 = vector.normalize!
        face = entities.add_face(entities.add_circle points[0], vector2, dim/2)
        face.followme(edges.all_connected)
        
        
        #group2.entities.add_group(group3)
        #group2.entities.add_group(parentGroup)
        #group2.entities.add_group(group)
       
    end

    def RF.rect(b,h,layer,group)

        #model2 = Sketchup.active_model
        #group2 = model2.active_entities.add_group
        group2 = group.entities.add_group
        entities2 = group2.entities
        #entities = group.entities
        #group.entities.add_group(group2)
        
        points = [
           Geom::Point3d.new(layer, layer, 0),
           Geom::Point3d.new(b-layer, layer, 0),
           Geom::Point3d.new(b-layer, h-layer, 0),
           Geom::Point3d.new(layer, h-layer, 0),
           Geom::Point3d.new(layer, layer, 0)
       ]

       entities2.add_line points
       #group.entities.add_group(group2)


    end

end